home *** CD-ROM | disk | FTP | other *** search
/ Linux 68k 2000 / Linux 68k 2000.iso / dokus / Cyrillic-HOWTO < prev    next >
Encoding:
Text File  |  1997-11-15  |  62.4 KB  |  1,498 lines

  1.   The Linux Cyrillic HOWTO
  2.   Alexander L. Belikoff, (abel@bfr.co.il), Berger Financial Research
  3.   Ltd.
  4.   v3.15, 14 November 1997
  5.  
  6.   This document describes how to set up your Linux box to typeset, view
  7.   and print the documents in the Russian language.
  8.  
  9.   1.  General notes
  10.  
  11.   1.1.  Introduction
  12.  
  13.   This document covers the things you need to successfully typeset,
  14.   view, and print documents in Russian under Linux. Although this
  15.   document assumes your using Linux as an operating system, most of
  16.   information presented is equally applicable to many other Unix
  17.   flavors. I shall try to keep the distinction as visible as possible.
  18.  
  19.   There are a number of popular Linux distributions. As an example
  20.   system I describe the RedHat 3.0.3 Linux (Picasso) and the RedHat 4.1
  21.   Linux (Vanderbildt) - the one I am personally using. Nevertheless, I
  22.   shall try to highlight the differences, if they exist, in the
  23.   Slackware Linux setup.
  24.  
  25.   Since such setup directly modifies and extends the Operating System,
  26.   you should understand, what you are doing. Even though I tried to keep
  27.   things as easy as possible, having some experience with a given piece
  28.   of software is an advantage. I am not going to describe what the X
  29.   Window System is or how to typeset the documents with TeX and LaTeX,
  30.   or how to install printer in Linux. Those issues are covered in other
  31.   documents.
  32.  
  33.   For the same reason, in most cases I describe a system-wide setup, by
  34.   default requiring root privileges. Still, if there is a possibility
  35.   for user-level setup, I'll try to mention it.
  36.  
  37.   NOTE: The X Window System, TeX and other Linux components are complex
  38.   systems with a sofisticated configuration. If you do something wrong,
  39.   you can not only fail with Russian setup, but to break the component
  40.   as well, if not the entire system. This is not to scare you off, but
  41.   merely to make you understand the seriousness of the process and be
  42.   careful. Preliminary backup of the config files is highly recommended.
  43.   Having a guru around is also advantageous.
  44.  
  45.   1.2.  Availability and feedback
  46.  
  47.   This document is available at sunsite.unc.edu or tsx-11.mit.edu as a
  48.   part of the Linux Document Project. Also, it may be available at
  49.   various FTP sites containing Linux. Moreover, it may be included as a
  50.   part of Linux distribution.
  51.  
  52.   If you have any suggestions or corrections regarding this document,
  53.   please, don't hesitate to contact me as abel@bfr.co.il. Any new and
  54.   useful information about Cyrillic support in various Unices is highly
  55.   appreciated. Remember, it will help the others.
  56.  
  57.   1.3.  Acknowledgments and copyrights
  58.  
  59.   Many people helped me (and not only me) with valuable information and
  60.   suggestions. Even more people contributed software to the public
  61.   community. I am sorry if I forgot to mention somebody.
  62.  
  63.   So, here they go:
  64.  
  65.   ╖  Bas V. de Bakker
  66.  
  67.   ╖  David Daves
  68.  
  69.   ╖  Serge Vakulenko
  70.  
  71.   ╖  Sergei O. Naoumov
  72.  
  73.   ╖  Winfried Truemper
  74.  
  75.   ╖  Ilya K. Orehov
  76.  
  77.   ╖  Michael Van Canneyt
  78.  
  79.   ╖  Alex Bogdanov
  80.  
  81.   ╖  relcom.fido.ru.unix and relcom.fido.ru.linux Usenet newsgroups.
  82.  
  83.   This document is Copyright (C) 1995,1997 by Alexander L. Belikoff. It
  84.   may be used and distributed under the usual Linux HOWTO terms
  85.   described below.
  86.  
  87.   The following is a Linux HOWTO copyright notice:
  88.  
  89.        Unless otherwise stated, Linux HOWTO documents are copy¡
  90.        righted by their respective authors. Linux HOWTO documents
  91.        may be reproduced and distributed in whole or in part, in
  92.        any medium physical or electronic, as long as this copyright
  93.        notice is retained on all copies. Commercial redistribution
  94.        is allowed and encouraged; however, the author would like to
  95.        be notified of any such distributions.
  96.  
  97.        All translations, derivative works, or aggregate works
  98.        incorporating any Linux HOWTO documents must be covered
  99.        under this copyright notice.  That is, you may not produce a
  100.        derivative work from a HOWTO and impose additional restric¡
  101.        tions on its distribution. Exceptions to these rules may be
  102.        granted under certain conditions; please contact the Linux
  103.        HOWTO coordinator at the address given below.
  104.  
  105.        In short, we wish to promote dissemination of this informa¡
  106.        tion through as many channels as possible. However, we do
  107.        wish to retain copyright on the HOWTO documents, and would
  108.        like to be notified of any plans to redistribute the HOWTOs.
  109.  
  110.   If you have questions, please contact Greg Hankins, the Linux HOWTO
  111.   coordinator, at gregh@sunsite.unc.edu. You may finger this address for
  112.   phone number and additional contact information.
  113.  
  114.   Unix is a technology trademark of the X/Open Ltd.; MS-DOS, Windows,
  115.   Windows 95, and Windows NT are trademarks of the Microsoft Corp.; The
  116.   X Window System is a trademark of The X Consortium Inc. Other
  117.   trademarks belong to the appropriate holders.
  118.  
  119.   2.  Characters and codesets
  120.  
  121.   In order to understand and print characters of various languages, the
  122.   system and software should be able to distinguish them from other
  123.   characters. That is, each unique character must have a unique
  124.   representation inside the operating system, or the particular software
  125.   package. Such collection of all unique characters, that the system is
  126.   able to represent at once, is called a codeset.
  127.  
  128.   At the time of the most operating system's creation, nobody cared
  129.   about software being multilingual. Therefore, the most popular codeset
  130.   was (and actually is) an ASCII (American Standard Code for Information
  131.   Interchange).
  132.  
  133.   The standard ASCII (aka 7-bit ASCII) comprises 128 unique codes. Some
  134.   of them ASCII defines as real printable characters, and some are so-
  135.   called control characters, which had special meanings in the old
  136.   communication protocols. Each element of the set is identified by an
  137.   integer character code (0-127). The subset of printable characters
  138.   represents those found on the typewriter's keyboard with some minor
  139.   additions. Each character occupies 7 least significant bits of a byte,
  140.   whereas the most significant one was used for control purposes (say,
  141.   transmission control in old communication packages).
  142.  
  143.   The 7-bit ASCII concept was extended by 8-bit ASCII (aka extended
  144.   ASCII). In this codeset, the characters' codes' range is 0-255. The
  145.   lower half (0-127) is pure ASCII, whereas the upper one contains 127
  146.   more characters. Since this codeset is backward compatible with the
  147.   ASCII (character still occupies 8 bit, the codes correspond the old
  148.   ASCII), this codeset gained wide popularity.
  149.  
  150.   The 8-bit ASCII doesn't define the contents of the upper half of the
  151.   codeset. Therefore the ISO organization took the responsibility of
  152.   defining a family of standards known as ISO 8859-X family. It is a
  153.   collection of 8-bit codesets, where the lower half of each codeset
  154.   (characters with codes 0-127) matches the ASCII and the upper parts
  155.   define characters for various languages. For example, the following
  156.   codesets are defined:
  157.  
  158.   ╖  8859-1 - Europe, Latin America (also known as Latin 1)
  159.  
  160.   ╖  8859-2 - Eastern Europe
  161.  
  162.   ╖  8859-5 - Cyrillic
  163.  
  164.   ╖  8859-8 - Hebrew
  165.  
  166.   In Latin 1, the upper half of the table defines various characters
  167.   which are not part of the English alphabet, but are present in various
  168.   european languages (german umlauts, french accentes etc).
  169.  
  170.   Another popular extended ASCII implementation is so-called IBM
  171.   codepage (named after some computer company, that developed this
  172.   codeset for it's infamous personal computers). This one contains
  173.   pseudo-graphic characters in the upper half.
  174.  
  175.   Software, that doesn't make any assumptions about the 8-th bit of the
  176.   ASCII data is called 8-bit clean. Some older programs, designed with
  177.   7-bit ASCII in mind are not 8-bit clean and may work incorrectly with
  178.   your extended ASCII data. Most of packages, however, are able to deal
  179.   with the extended ASCII by default, or require some very basic setup.
  180.   NOTE: before posting the question "I did all setup right, but I cannot
  181.   enter/view Cyrillic characters!", please consult the section ``'' for
  182.   the notes on the program, you are using.
  183.  
  184.   For information about making your software 8-bit clean, see section
  185.   ``''.
  186.  
  187.   Since on most systems character occupies 8 bits, there is no way to
  188.   extend ASCII more and more. The way to implement new symbols in ASCII-
  189.   based codesets is creation of other extended ASCII implementations.
  190.   This is the way, the Cyrillic ASCII set is implemented.
  191.  
  192.   We already mentioned ISO 8859-5 standard as the one defining the
  193.   Cyrillic codeset. But as it often happens to the standards, this one
  194.   was developed without taking into account the real practices in the
  195.   former USSR. Therefore, one thing that standard really achieved was
  196.   another degree of confusion. I wouldn't say that ISO 8859-5 is widely
  197.   used anywhere.
  198.  
  199.   Other standards for Cyrillic include the so-called Alt codeset and
  200.   Microsoft CP1251 codepage. The former one was developed by (who?) for
  201.   MS-DOS quite a while ago. Back then, there was not very buzz yet about
  202.   internetworking, so the intention was to make it as compatible as
  203.   possible with the IBM standard. Therefore the Alt codeset is
  204.   effectively the same IBM codepage, where all specific European
  205.   characters in the upper half were replaced with the Cyrillic ones,
  206.   leaving the pseudographic ones. Therefore, it didn't screw the text
  207.   windowing facilities and provided Cyrillic characters as well.  The
  208.   Alt standard is still alive and extremely popular in MS-DOS.
  209.  
  210.   Microsoft CP1251 codepage is just an attempt of Microsoft to come up
  211.   with the new standard for Cyrillic codeset in Windows. As far as I
  212.   know, it is not compatible with anything else (not very surprizing,
  213.   huh?)
  214.  
  215.   And finally there is KOI-8. This one is also quite old, but it was
  216.   designed wisely and nowadays the design points of it look really
  217.   useful.
  218.  
  219.   Again, it is compatible with ASCII, and the Cyrillic characters are
  220.   located in the upper half. But the main design point of KOI-8 is that
  221.   the Cyrillic characters' positions must correspond to the English
  222.   characters with the same phonetics. Namely, if we set the eighth bit
  223.   of the English character 'a', we'll get the Cyrillic 'a'.  This means
  224.   that, given the Cyrillic text written in KOI-8, we can strip the
  225.   eighth bit of each character and we still get a readable text,
  226.   although written with English characters! This is very important now,
  227.   since there are many mailers on the Internet, that just strip the
  228.   eighth bit silently, being sure that every single soul on the face of
  229.   the Earth speaks English.
  230.  
  231.   Not surprisingly, KOI-8 quickly became a de-facto standard for
  232.   Cyrillic on the Internet. Andrew A. Chernov did a tremendous amount of
  233.   work to make a standard in this area. He is an author of RFC 1489
  234.   ("Registration of a Cyrillic Character Set").
  235.  
  236.   These two standards differ only in positions of the cyrillic
  237.   characters in the table (that is in cyrillic character codes).
  238.  
  239.   The principal difference is that the Alt codeset is used by MS-DOS
  240.   users only, whereas KOI-8 is used in Unix, as well as in MS-DOS
  241.   (though in the latter KOI-8 is much less popular). Since we are doing
  242.   the right thing (namely working in the Unix operating system), we
  243.   shall focuse mostly on KOI-8.
  244.  
  245.   As for the ISO standard, it is more popular in Europe and the US as a
  246.   standard for Cyrillic. The leader in Russia is definitely KOI-8.
  247.  
  248.   There are other standards, which are different from ASCII and much
  249.   more flexible. Unicode is most known. However, they are not
  250.   implemented as good as the basic ones in Unix in general and  Linux in
  251.   particular. Therefore, I am not describing them here.
  252.  
  253.   3.  Text mode setup
  254.  
  255.   Generally, the text mode setup is the easiest way to show and input
  256.   Cyrillic characters. There is one significant complication, however:
  257.   the text mode fonts and keyboard layout manipulations depend on
  258.   terminal driver implementation. Therefore, there is no portable way to
  259.   achieve the goal across different systems.
  260.  
  261.   Right now, I describe the way to deal with the Linux console driver.
  262.   Thus, if you have another system, don't expect it to work for you.
  263.   Instead, consult your terminal driver manual. Nevertheless, send me
  264.   any information you find, so I'll be able to include it in further
  265.   versions of this document.
  266.  
  267.   3.1.  Linux Console
  268.  
  269.   The Linux console driver is quite a flexible piece of software. It is
  270.   capable of changing fonts as well as keyboard layouts. To achieve it,
  271.   you'll need the kbd package. Both RedHat and Slackware install kbd as
  272.   part of a system.
  273.  
  274.   The kbd package contains keyboard control utilities as well as a big
  275.   collection of fonts and keyboard layouts.
  276.  
  277.   Cyrillic setup with kbd usually involves two things:
  278.  
  279.   1. Screen font setup. This is performed by the setfont program. The
  280.      fonts files are located in /usr/lib/kbd/consolefonts.
  281.  
  282.      NOTE: Never run the setfont program under X because it will hang
  283.      your system. This is because it works with low-level video card
  284.      calls which X doesn't like.
  285.  
  286.   2. Load the appropriate keyboard layout with the loadkeys program.
  287.  
  288.   NOTE: In RedHat 3.0.3, /usr/bin/loadkeys has too restrictive access
  289.   permissions, namely 700 (rwx------). There are no reasons for that,
  290.   since everyone may compile his own copy and execute it (the
  291.   appropriate system calls are not root-only). Thus, just ask your
  292.   sysadmin to set more reasonable permissions for it (for example, 755).
  293.  
  294.   The following is an excerpt from my cyrload script, which sets up the
  295.   Cyrillic mode for Linux console:
  296.  
  297.   if [ notset.$DISPLAY != notset. ]; then
  298.       echo "`basename $0`:  cannot run under X"
  299.       exit
  300.   fi
  301.  
  302.   loadkeys /usr/lib/kbd/keytables/ru.map
  303.   setfont /usr/lib/kbd/consolefonts/Cyr_a8x16
  304.   mapscrn /usr/lib/kbd/consoletrans/koi2alt
  305.   echo -ne "\033(K"              # the magic sequence
  306.   echo "Use the right Ctrl key to switch the mode..."
  307.  
  308.   Let me explain it a bit. You load the appropriate keyboard mapping.
  309.   Then you load a font corresponding to the Alt codeset. Then, in order
  310.   to be able to display text in KOI8-R correctly, you load a screen
  311.   translation table. What it does is a translation of some characters
  312.   from the upper half of the codeset to the Alt encoding. The word
  313.   'some' is crucial here - not all characters get translated, therefore
  314.   some of them, like IBM pseudographic characters get unmodified to the
  315.   screen and display correctly, since they are compatible with the Alt
  316.   codeset, as opposed to KOI8-R. To ensure this, run mc and pretend you
  317.   are back to MS-DOS 3.3...
  318.  
  319.   Finally, the magic sequence is important but I have no idea what on
  320.   the Earth it does. I stole/borrowed/learned it from German HOWTO back
  321.   in 1994, when it was like the only national language oriented HOWTO.
  322.   If you have any idea about this magic sequence, please tell me.
  323.  
  324.   Finally, for those purists, who don't wont to give the Alt codeset a
  325.   chance, I'm attaching yet another version of the script above, using
  326.   native KOI8-R fonts.
  327.  
  328.   if [ notset.$DISPLAY != notset. ]; then
  329.       echo "`basename $0`:  cannot run under X"
  330.       exit
  331.   fi
  332.  
  333.   loadkeys /usr/lib/kbd/keytables/ru.map
  334.   setfont /usr/lib/kbd/consolefonts/koi-8x16
  335.   echo "Use the right Ctrl key to switch the mode..."
  336.  
  337.   However, don't expect nice borders in your text mode-based windowing
  338.   applications.
  339.  
  340.   Now you probably want to test it. Do the appropriate bash or tcsh
  341.   setup, rerun it, then press the right Control key and make sure you
  342.   are getting the cyrillic characters right. The 'q' key must produce
  343.   russian "short i" character, 'w' generates "ts", etc.
  344.  
  345.   If you've screwed something up, the very best thing to do is to reset
  346.   to the original (that is, US) settings. Execute the following
  347.   commands:
  348.  
  349.   loadkeys /usr/lib/kbd/keytables/defkeymap.map
  350.   setfont /usr/lib/kbd/consolefonts/default8x16
  351.  
  352.   NOTE: unfortunately enough, the console driver is not able to preserve
  353.   it's state (at least easily enough), while running the X Window
  354.   System. Therefore, after you leave the X (or switch from it to a
  355.   console), you have to reload the console russian font.
  356.  
  357.   3.2.  FreeBSD Console
  358.  
  359.   I am not using FreeBSD so I couldn't test the following information.
  360.   All data in this section should be treated as just pointers to begin
  361.   with. The FreeBSD project homepage may have some information on the
  362.   subject. Another good source is the relcom.fido.ru.unix newsgroup.
  363.   Also, check the resources listed in section ``''.
  364.  
  365.   Anyway, this is what Ilya K. Orehov suggests to do in order to make
  366.   FreeBSD console speak Russian:
  367.  
  368.   1. In /etc/sysconfig add:
  369.  
  370.      keymap=ru.koi8-r
  371.      keyrate=fast
  372.      # NOTE: '^[' below is a single control character
  373.      keychange="61 ^[[K"
  374.      cursor=destructive
  375.      scrnmap=koi8-r2cp866
  376.      font8x16=cp866b-8x16
  377.      font8x14=cp866-8x14
  378.      font8x8=cp866-8x8
  379.  
  380.   2. In /etc/csh.login:
  381.  
  382.      setenv ENABLE_STARTUP_LOCALE
  383.      setenv LANG ru_SU.KOI8-R
  384.      setenv LESSCHARSET latin1
  385.  
  386.   3. Make analogous changes in /etc/profile
  387.  
  388.   4.  The X Window System
  389.  
  390.   Like the console mode, the X environment also requires some setup.
  391.   This involves setting up the input mode and the X fonts. Both are
  392.   being discussed below.
  393.  
  394.   4.1.  The X fonts.
  395.  
  396.   First of all, you have to obtain the fonts having the Cyrillic glyphs
  397.   at the appropriate positions.
  398.  
  399.   If you are using the most recent X (or XFree86) distribution, chances
  400.   are, that you already have such fonts. In the late 1995, the X Window
  401.   System incorporated a set of Cyrillic fonts, created by Cronyx. Ask
  402.   your system administrator, or, if you are the one, check your system,
  403.   namely:
  404.   1. Run 'xlsfonts | grep koi8'. If there are fonts listed, your X
  405.      server is already aware about the fonts.
  406.  
  407.   2. Otherwise, run
  408.  
  409.      find -name crox\*.pcf\*
  410.  
  411.   to find the location of the Cyrillic fonts in the system. You'll have
  412.   to enable those fonts to the X server, as I explain below.
  413.  
  414.   If you haven't found such fonts installed, you'll have to do it
  415.   yourself.
  416.  
  417.   There is some ambiguity with the fonts. XFree86 docs claim that the
  418.   russian fonts collection included in the distribution is developed by
  419.   Cronyx. Nevertheless, you may find another set of Cronyx Cyrillic
  420.   fonts on the net (eg. on ftp.kiae.su), known as the xrus package
  421.   (don't confuse it with the xrus program, which is used to setup a
  422.   Cyrillic keyboard layout. Hopefully, tha letter one was renamed to
  423.   xruskb recently). Xrus has fewer fonts than the collection in Xfree86
  424.   (38 vs 68), but the latter one didn't go along with my ``Netscape''
  425.   setup - it gave me some really huge font in the menubar. The xrus
  426.   package doesn't have this problem.
  427.  
  428.   I would suggest you to download and try both of them. Pick up the one
  429.   which you'll like more. Also, I'm going to creat RPM packages soon for
  430.   both collections and download them both to ftp.redhat.com and to my
  431.   FTP site.
  432.  
  433.   There are also older stuff, for example the vakufonts package, created
  434.   by Serge Vakulenko, which was the base for the one in the X
  435.   distribution. There are also a number of others. The important point
  436.   is that the fonts' names in the old collection were not strictly
  437.   conforming to the standard. The latter is fine in general, but
  438.   sometimes it may cause various weird errors. For example, I had a bad
  439.   experience with Maple V for Linux, which crashed mysteriously with the
  440.   vakufonts package, but ran smoothly with the "standard" ones.
  441.  
  442.   So, let's start with the fonts:
  443.  
  444.   1. Download the appropriate fonts collection. The package for XFree86
  445.      may be found at any FTP site, containing the X distribution, for
  446.      example, directly from the XFree86 FTP site. The xrus package may
  447.      be found on ftp.kiae.su
  448.  
  449.   2. Now when you have the fonts, you create some directory for them. It
  450.      is generally a bad idea to put new fonts to the already existing
  451.      font directory. So, place them, to, say,
  452.      /usr/lib/X11/fonts/cyrillic for a system-wide setup, or just create
  453.      a private directory for personal use.
  454.  
  455.   3. If the new fonts are in BDF format (*.bdf files), you have to
  456.      compile them. For each font do:
  457.  
  458.      bdftopcf -o <font>.pcf <font>.bdf
  459.  
  460.   If your server supports compressed fonts, do it, using the compress
  461.   program:
  462.  
  463.   compress *.pcf
  464.  
  465.   Also, if you do want to put the new fonts to an already existing font
  466.   directory. you have to concatenate the old and the new files named
  467.   fonts.alias in the case both of them exist.
  468.  
  469.   4. Each font directory in the X must contain a list of fonts in it.
  470.      This list is stored in the file fonts.dir. You don't have to create
  471.      this list manually. Instead, do:
  472.  
  473.      cd <new font directory>
  474.      mkfontdir .
  475.  
  476.   5. Now you have to make this font directory known to the X server.
  477.      Here, you have a number of options:
  478.  
  479.   ╖  System-wide setup for XFree86. If you are running this version of
  480.      X, then append the new directory to the list of directories in the
  481.      file XF86Config. To find the location of this file, see output of
  482.      startx. Also, see XF86Config(4/5) for details.
  483.  
  484.   ╖  System-wide setup through xinit. Add the new directory to the xinit
  485.      startup file. See xinit(1x) and the next option for details.
  486.  
  487.   ╖  Personal setup. You have a special start-up file for the X -
  488.      ~/.xinitrc (or ~/.Xclients, or ~/.xsession for the RedHat users).
  489.      Add the following commands to it:
  490.  
  491.      xset +fp <new font directory>
  492.      xset fp rehash
  493.  
  494.   It is important to note that '+fp' means that the new fonts will be
  495.   added to the head of the font path list. That is, if an application
  496.   requests say a fixed font, it'll be given the one with Cyrillic char¡
  497.   acters, which is definitely what we are trying to achieve.
  498.  
  499.   There are problems, though. The fixed font in the cyrillic fonts dis¡
  500.   tribution doesn't have it's bold and italic counterparts. My font of
  501.   choice is 6x13, so, since it also lacks bold and italic typefaces, I
  502.   cannot use Emacs/XEmacs faces in their full glory. Hopefully somebody
  503.   will ultimately create those fonts and the situation will change.
  504.  
  505.   6. Now restart your X. If you have done everything right, the tests in
  506.      the beginning of the section will be successful. Also, play with
  507.      xfontsel(1x) to make sure you are able to select the cyrillic
  508.      fonts.
  509.  
  510.   In order to make the X clients use the Cyrillic fonts, you have to set
  511.   up the appropriate X resources. For example, I make the russian font
  512.   the default one in my ~/.Xdefaults:
  513.  
  514.   *font:         6x13
  515.  
  516.   Since my cyrillic fonts are first in the font path (see output of
  517.  
  518.   This just a simple case. If you want to set the appropriate part of
  519.   the X client to a cyrillic font, you have to figure out the name of
  520.   the resource (eg. using editres(1x)) and to specify it either in the
  521.   resource database, or in the command line. Here go some examples:
  522.  
  523.   $ xterm -font '-cronyx-*-bold-*-*-*-19-*-*-*-*-*-*-*'
  524.  
  525.   $ xfontsel -xrm '*quitButton.font: -*-times-*-*-*-*-13-*-*-*-*-*-koi8-*'
  526.  
  527.   xfontsel.
  528.  
  529.   4.2.  The input translation
  530.  
  531.   In the newest X releases (X11R61 and higher) there are two "standard"
  532.   input methods: the original one, working through the xmodmap utility,
  533.   and the new one called Xkb (X KeyBoard). The very first thing you have
  534.   to do is to disable the Xkb method! Don't get charmed by it's ability
  535.   to set up a "russian keyboard". It looks like this method is using the
  536.   Cyrillic keysyms defined in keysymdef.h. This file defines keysyms for
  537.   many languages. The only problem is that those definitions have
  538.   nothing to do with the extended ASCII codeset - the one most programs
  539.   are only able to operate with! I hardly know any programs being able
  540.   to grok the keysymdef.h keysyms, different from 8-bit ASCII. However
  541.   our goal is to get the KOI8-R support to work.
  542.  
  543.   To disable the Xkb support, browse through the Keyboard section of
  544.   your XF86Config file and comment all lines starting with Xkb (case
  545.   doesn't matter). Instead, put the following line:
  546.  
  547.   XkbDisable
  548.  
  549.   The xmodmap program.allows customization of codes emitted by various
  550.   characters and their combinations. It sets the things up based on the
  551.   file containing the translation table.
  552.  
  553.   In the previous versions of this document I used to describe the
  554.   xmodmap-based setup in a great detail. This proved to be almost
  555.   useless. The Xmodmap-based input translation method is well known as
  556.   being it is non-portable, inflexible, and incomplete.  Your
  557.   configuration may work with one XFree version and fail with a
  558.   different one. Even worse, sometimes things differ accross different
  559.   servers in the same distribution.
  560.  
  561.   I strongly suggest you not to play with this xmodmap, at least for
  562.   now. Apart from headache and disappointment you'll gain nothing.
  563.   Instead, I recommend installing the xruskb package, which allows you
  564.   to configure most of the input translation parameters without having
  565.   to know about xmodmap. Again, the RedHat Linux users are free to
  566.   download and install an RPM package.
  567.  
  568.   5.  Cyrillic support in TeX and LaTeX
  569.  
  570.   In this section I'll describe several ways to make TeX and LaTeX
  571.   typeset Cyrillic texts. There are several ways, which differ in setup
  572.   sophistication and usage convenience. For example, one possibility is
  573.   to start without any preliminary setup and use the Washington AMSTeX
  574.   Cyrillic fonts. On the other hand, you may install a LaTeX package,
  575.   providing a very high degree of Cyrillic setup. I have an experience
  576.   with two such packages. One is the cmcyralt package by Vadim V.
  577.   Zhytnikov (vvzhy@phy.ncu.edu.tw) and Alexander Harin
  578.   (harin@lourie.und.ac.za), and the other one is the LH package by the
  579.   CyrTUG group with styles and hyphenation for LaTeX2e by Sergei O.
  580.   Naoumov (serge@astro.unc.edu). I'll describe both.
  581.  
  582.   Note, that there are two versions of LaTeX available - 2.09 is the old
  583.   one, while 2e is a new pre-3.0 release. If you are using LaTeX 2.09,
  584.   then switch quickly to the 2e. The latter retains compatibility with
  585.   the old one, but has much more features. Hopefully, version 3 will be
  586.   released soon. I describe a LaTeX 2e setup.
  587.  
  588.   Also, both of these packages require the Cyrillic text to be typeset
  589.   using the Alt codeset, not KOI-8! This is caused by historical
  590.   reasons, since the creators of these packages used to work with EmTeX
  591.   - the MS-DOG version of TeX (they didn't know about Linux yet :-).
  592.   Switching to the KOI-8 requires some effort and is being expected to
  593.   be done soon. So far, use some utility to convert your russian text
  594.   from KOI-8 to Alt. See section ``''.
  595.  
  596.   5.1.  Using the Washington Cyrillic
  597.  
  598.   This package was created for the American Mathematic Society to
  599.   provide documents with Russian references. Therefore, the authors were
  600.   not very careful and the fonts look quite clumsy. This package is
  601.   usually referred to as a "really bad cyrillic package for TeX".
  602.  
  603.   Nevertheless, we'll discuss it, because it is very easy to use and
  604.   doesn't require any setup - this collection is supplied with most of
  605.   TeX distributions.
  606.  
  607.   Of course, you won't be able to use such luxury as automatic
  608.   hyphenation, but anyway...
  609.  
  610.   1. Prepend your document with the following directives:
  611.  
  612.   \input cyracc.def
  613.   \font\tencyr=wncyr10
  614.   \def\cyr{\tencyr\cyracc}
  615.  
  616.   2. Now to type a cyrillic letter, you enter
  617.  
  618.   \cyr
  619.  
  620.   and use a corresponding latin letter or a TeX command. Thus, the lower
  621.   case of the Russian alphabet is expressed by the following codes:
  622.  
  623.   a b v g d e \"e zh z i {\u i} k l m n o p r s t u f kh c ch sh shch
  624.   {\cprime} y {\cdprime} \`e yu ya
  625.  
  626.   It is extremely inconvenient to convert your Russian texts to such
  627.   encoding, but you can automate the process. The translit program
  628.   (section ``'') supports a TeX output option.
  629.  
  630.   5.2.  KOI-8 package for teTeX
  631.  
  632.   There is some new teTeX-rus package. It is reported to support KOI-8
  633.   character set and have all basic stuff required for TeX and LaTeX. I
  634.   personally haven't tried it yes, although I heard about it's
  635.   successfull usage.
  636.  
  637.   NOTE: This package requires you to reconfigure and rebuild some parts
  638.   of your teTeX package (for example the precompiled LaTeX macros).
  639.   Unless you know what you are doing, you shouldn't try it without
  640.   necessary care. Otherwise, you may be better off by borrowing the
  641.   precompiled parts fron somebody on the net
  642.  
  643.   5.3.  Using the cmcyralt package for LaTeX
  644.  
  645.   The cmcyralt package can be found on any CTAN (Comprehensive TeX
  646.   Archive Network) site like ftp.dante.de. You should obtain two pieces:
  647.   the fonts collection from fonts/cmcyralt and the styles and
  648.   hyphenation rules from macros/latex/contrib/others/cmcyralt.
  649.  
  650.   Note: Make sure you have the Sauter package installed, since cmcyralt
  651.   requires some fonts from it. You can get this package from CTAN site
  652.   as well.
  653.  
  654.   Now you should do the following:
  655.  
  656.   1. Put the new fonts to the TeX fonts tree. On my system (Slackware
  657.      2.2) I created a cmcyralt directory in the
  658.      /usr/lib/texmf/fonts/cm/. Create the src, tfm, and vf
  659.      subdirectories in it. Put there .mf, .tfm, and vf files
  660.      respectively.
  661.  
  662.   2. Put the font driver files (*.fd) from the styles archive to the
  663.      appropriate place (in my case it was /usr/lib/texmf/tex/latex/fd).
  664.  
  665.   3. Put the style files (*.sty) to the appropriate LaTeX styles
  666.      directory (in my case /usr/lib/texmf/tex/latex/sty).
  667.  
  668.   Now the hyphenation setup. This requires to remake the LaTeX base
  669.   file.
  670.  
  671.   1. The file hyphen.cfg contains the directives for both English and
  672.      Russian hyphenation. Extract the one for Russian and place it to
  673.      the LaTeX hyphenation config file lthyphen.ltx. In my case, that
  674.      file was in /usr/lib/texmf/tex/latex/latex-base.
  675.  
  676.   2. Put the rhyphen.tex to the same directory. It is needed for making
  677.      the new base file. Later, you can remove it.
  678.  
  679.   3. Do 'make' in that directory. Don't for get to make a link from
  680.      Makefile to Makefile.unx. During the make process check the output.
  681.      There should be a message:
  682.  
  683.      Loading hyphenation patterns for Russian.
  684.  
  685.   If everything goes OK, you will get the new latex.fmt in that direc¡
  686.   tory. Put it to the appropriate place, where the previous one was
  687.   (like /usr/lib/texmf/ini/). Don't forget to save the previous one!.
  688.  
  689.   This is it. The installation is complete. Try processing the examples
  690.   found in the styles archive. If you are to create the PostScript files
  691.   without any problems, then everything is OK. Now, to use Cyrillic in
  692.   LaTeX, prepend your document with the following directive:
  693.  
  694.   \usepackage{cmcyralt}
  695.  
  696.   For more details, see the README file in the cmcyralt styles archive.
  697.  
  698.   Note: if you do have problems with the examples, provided you have
  699.   installed the things right, then probably your TeX system hasn't been
  700.   installed correctly. For example, during my first try, every attempt
  701.   to create the .pk files for the russian fonts failed (MakeTeXPK
  702.   stage). A substantial investigation discovered some implicit conflict
  703.   between the localfont and ljfour METAFONT configurations. It used to
  704.   work before, but kept crashing after the cmcyralt installation.
  705.   Contact your local TeX guru - TeX is very (sometimes too much)
  706.   complicated to reconfigure it without any prior knowledge.
  707.  
  708.   5.4.  Using the CyrTUG package
  709.  
  710.   You can obtain the CyrTUG package from the SunSite archive. Get the
  711.   files CyrTUGfonts.tar.gz, CyrTUGmacro.tar.gz, and hyphen.tar.Z.
  712.  
  713.   The process of installation doesn't differ from too much the previous
  714.   one.
  715.  
  716.   6.  Cyrillic in PostScript
  717.  
  718.   Experts say PostScript is easy. I cannot judge - I've got too many
  719.   things to learn to spare some time to learn PostScript. So I'll try to
  720.   use my sad experience with it. I'll appreciate any feedback from you
  721.   guys who know more on the subject than I do (approx. 99% of the Earth
  722.   population).
  723.  
  724.   Basically, in order to print a Cyrillic text using PostScript, you
  725.   have to make sure about the following things:
  726.  
  727.   ╖  Cyrillic font is loaded or included in the document.
  728.  
  729.   ╖  Cyrillic text is included in the document.
  730.  
  731.   ╖  Cyrillic text uses the appropriate character codes which correspond
  732.      to the font's requirements.
  733.  
  734.   ╖  An appropriate font is selected in order to print Cyrillic text.
  735.  
  736.   There is no solution general enough to be recommended as an ultimate
  737.   treatment. I'll try to outline various ways to cope with different
  738.   problems related to the subject.
  739.  
  740.   One way to address Cyrillic setup problems generally enough is to use
  741.   Ghostscript. Ghostscript (or just gs in the newspeak) is a free (well
  742.   quasi-free) PostScript interpreter. It has many advantages; among
  743.   them:
  744.  
  745.   ╖  Ability to run on many platforms (various Unices, Windows etc)
  746.  
  747.   ╖  Support for a wide number of non-PostScript printers
  748.  
  749.   ╖  Good degree of configurability
  750.  
  751.   What is important in our particular case, is that once Ghostscript is
  752.   set up, we can do all printing through it, thus eliminating extra
  753.   setup for other PostScript devices (for example HP LaserJet IV)
  754.  
  755.   6.1.  Adding Cyrillic fonts to Ghostscript
  756.  
  757.   This is important, since you probably don't want to put a
  758.   responsibility to other programs to insert Cyrillic fonts in the
  759.   PostScript output. Instead, you add them to gs and just make the
  760.   programs generate Cyrillic output compatible with the fonts.
  761.  
  762.   To add a new font (in pfa or pfb form) in gs, you have to:
  763.  
  764.   1. Put it in the gs fonts directory (ie.  /usr/lib/ghostscript/fonts).
  765.  
  766.   2. Add the appropriate names and aliases for the font in the Fontmap
  767.      file in the gs directory.
  768.  
  769.   Recently a decent set of Cyrillic fonts for GhostScript appeared.  It
  770.   is located in ftp.kapella.gpi.ru. This one even has a necessary part
  771.   to add to the Fontmap file. You have to download the contents of the
  772.   /pub/cyrillic/psfonts directory. The README file describes the
  773.   necessary details.
  774.  
  775.   7.  Print setup
  776.  
  777.   Printing is always tricky. There are different printers from different
  778.   vendors with different facilities. Even for a native printing there is
  779.   no uniform solution (this applies not only to UNIX, but to other
  780.   operating systems as well.
  781.  
  782.   Printers have different control languages and often they have very
  783.   different views on foreign language support.  The good news is that on
  784.   control language seems to be recognized as a de-facto standard for
  785.   print job description - it is a PostScript language developed by Adobe
  786.   Corporation.
  787.  
  788.   Another problem is a variety of requirements to the print services.
  789.   For example, sometimes you want just to print a piece if C program,
  790.   containing comments in Russian, so you don't need any pretty-printing
  791.   - just a raw ASCII output in a single font. Another time, when you
  792.   design a postcard for your girlfriend, you'll probably need to typeset
  793.   some document with different fonts etc. This will definitely require
  794.   more effort to setup Cyrillic support.
  795.  
  796.   To accomplish the former task you just have to make your printer
  797.   understand one Cyrillic font and (maybe) install some filter program
  798.   to generate data in appropriate format. To accomplish the latter one,
  799.   you have to teach your printer different fonts and have a special
  800.   software.
  801.  
  802.   There is also something in the middle, when you get a program which
  803.   knows how to generate both the fonts and the appropriate printer
  804.   input, so you can say do some aource code pretty-printing without
  805.   sophisticated word processing systems.
  806.  
  807.   All these options will be more or less covered below.
  808.  
  809.   7.1.  Pre-loading Cyrillic fonts into a non-PostScript printer
  810.  
  811.   If you have a good old dot matrix printer and all you need is to print
  812.   a raw KOI-8 text, try the following:
  813.  
  814.   1. Find a proper KOI-8 font for your printer. Check out the MS-DOSish
  815.      stuff on the Internet (for example the SimTel archive
  816.      <ftp://ftp.simtel.net>).
  817.  
  818.   2. Learn from the manual, how to load such font into your printer and,
  819.      probably, write a simple program doing that.
  820.  
  821.   3. Run this program from the appropriate rc file at a boot time.
  822.  
  823.   Thus, having Cyrillic characters in the upper part of the printer's
  824.   character set will allow you to print you texts in Russian without any
  825.   hussle.
  826.  
  827.   Alternatively to the KOI-8 fonts you may try to use the Alt font.
  828.   There are two reasons for that:
  829.  
  830.   ╖  It may be probably much easier to find an Alt font, since those
  831.      were very widespread in the MS-DOS culture.
  832.  
  833.   ╖  Having a proper Alt font will allow you to print pseudo-graphic
  834.      characters as well.
  835.  
  836.   However in this case, you'll have to convert your texts from KOI-8 to
  837.   Alt before sending them to a printer. This is quite easy, since there
  838.   are a lot of programs doing that (see ``translit'' for example), so
  839.   you just have to call such program properly in the if field in
  840.   /etc/printcap file. For example, with the translit program you may
  841.   specify:
  842.  
  843.   if=/usr/bin/translit -t koi8-alt.rus
  844.  
  845.   See printcap(5) for details.
  846.  
  847.   7.2.  Printing with different fonts
  848.  
  849.   One great way to cope with different printers and fonts is to use TeX
  850.   (see section ``''). TeX drivers handle all details, so once you make
  851.   TeX understand Cyrillic fonts, you are done.
  852.  
  853.   Another possibility is to use PostScript. I decided to devote an
  854.   entire chapter ``'' to the subject, since it is not simple.
  855.  
  856.   Finally, there are other word processors, which have printer drivers.
  857.   I never tried anything apart from TeX, so I cannot suggest anything.
  858.  
  859.   7.3.  Converting text to TeX
  860.  
  861.   If all you need is just to print an ASCII text without any additional
  862.   word processing, you may try to use some programs, which would convert
  863.   your Cyrillic text to a ready-to-process TeX file. One of the best
  864.   programs for such purposes is ``translit''. In this case, you don't
  865.   even have to bother about installing the Cyrillic fonts for TeX, since
  866.   translit uses a Washington Cyrillic package, which is included in most
  867.   TeX distributions (or am I wrong?)
  868.  
  869.   7.4.  Text to PostScript converters
  870.  
  871.   Sometimes you have just a plain ASCII KOI-8 text and you want to print
  872.   it just to get it on the paper. One of the easiest ways to achieve
  873.   that is to use special programs converting text to PostScript.
  874.  
  875.   There are a number of programs doing such conversion. I personally
  876.   prefer a2ps. Originally developed as a simple text-to-PostScript
  877.   converter it became a big and highly configurable program with many
  878.   options and allows you to manage various page layouts, syntax
  879.   highlighting etc. Another tool (now available as a part of the GNU
  880.   project) is enscript.
  881.  
  882.   The main problem with such programs is that they know nothing about
  883.   Cyrillic fonts. Right now I am investigating a possibility of
  884.   including Cyrillic fonts in them in order to understand Cyrillic. Stay
  885.   in touch.
  886.  
  887.   Nevertheless all the blah-blah above would be pointless without any
  888.   real advice. So, there we go.
  889.  
  890.   7.4.1.  An a2ps converter
  891.  
  892.   A text to PostScript converter has been around for a while and is one
  893.   of the most versatile printing tools. The author proved to be very
  894.   open to suggestions, so since the release 4.9.8 a2ps supports Cyrillic
  895.   right off-the-shelf. All you need is a PostScript printer.
  896.  
  897.   The command I use is:
  898.  
  899.   a2ps -X koi8r --print-anyway  <file>
  900.  
  901.   7.4.2.  The GNU enscript
  902.  
  903.   The GNU enscript program is also designed for converting text to
  904.   PostScript and it also has a non-ASCII codeset support. It doesn't
  905.   have Cyrillic PostScript fonts, but it is very easy to get them, as
  906.   will be explained below (thanks to Michael Van Canneyt):
  907.  
  908.   1. Install the newest enscript. As of now, the most recent release is
  909.      1.5. You may either get the one from the GNU FTP archive, or take
  910.      an RPM package from the Redhat site.
  911.  
  912.   2. Now, if you are a lucky RedHat Linux user, download and install
  913.      Cyrillic Textbook font
  914.      <ftp://ftp.redhat.com/pub/contrib/i386/enscript-fonts-
  915.      koi8-1.0-1.i386.rpm>.
  916.  
  917.   3. If you don't use RPM, download a file textbook.tar.gz from the
  918.      Cyrillic Software collection on sunsite.unc.edu
  919.      <ftp://sunsite.unc.edu/pub/academic/russian-studies/Software/>.
  920.      Extract it to a directory, where enscript fonts are located
  921.      (usually /usr/share/enscript). Now change to that directory and run
  922.      the following command:
  923.  
  924.          mkafmmap *.afm
  925.  
  926.   4. The setup is finished. Try to print some text in KOI8-R Cyrillic
  927.      with the following command:
  928.  
  929.          enscript --font=Textbook8 --encoding=koi8 some.file
  930.  
  931.   If you want a really quick and dirty solution and you don't care about
  932.   the output quality and all you need is just Cyrillic on the paper, try
  933.   the rtxt2ps package. It is a very simple no-frills text-to-PostScript
  934.   conversion program. The output quality is not very good (or, to be
  935.   honest, just bad) but it does it's job.
  936.  
  937.   8.  Miscellaneous utilities setup
  938.  
  939.   Generally, to set the certain utility up to handle the Cyrillic
  940.   requires just to allow the 8 bit input. In some cases it is required
  941.   to tell the application to show the extended ASCII characters in their
  942.   "native" form.
  943.  
  944.   8.1.  bash
  945.  
  946.   Three variables should be set on order to make bash understand the
  947.   8-bit characters. The best place is ~/.inputrc file. The following
  948.   should be set:
  949.   set meta-flag on
  950.   set convert-meta off
  951.   set output-meta on
  952.  
  953.   8.2.  csh/tcsh
  954.  
  955.   The following should be set in .cshrc:
  956.  
  957.   setenv LC_CTYPE iso_8859_5
  958.   stty pass8
  959.  
  960.   If you don't have the POSIX stty (impossible for Linux), then replace
  961.   the last call to the following:
  962.  
  963.   stty -istrip cs8
  964.  
  965.   8.3.  dosemu
  966.  
  967.   This seems to be the only application, which may require Alt Cyrillic
  968.   character set. The reason is that Alt is native to DOS and most of DOS
  969.   programs dealing with Cyrillic are Alt-oriented.
  970.  
  971.   For the console version (dos) you just have to load a keyboard and
  972.   screen driver. Most of DOS drivers will work fine. I personally use
  973.   the rk driver by A. Strakhov, which works for both console and X
  974.   versions of dosemu. Another choice is the r driver by V. Kurland
  975.   (sorry for possible misspelling). It is perfectly customizable and
  976.   supports many codesets, Alt and KOI8 among them. However it won't work
  977.   for the X window (at least version 1.14 I'm using).
  978.  
  979.   Both drivers can be found on most Russian Internet sites, for example
  980.   Kurchatov Institute FTP server <ftp://ftp.kiae.su/pub/cyrillic/msdos>.
  981.  
  982.   For the X version of dosemu you have to provide an appropriate X font
  983.   as well. Alex Bogdanov sent me such font by e-mail. It is an original
  984.   vga font from the dosemu distribution, modified for the Alt codeset.
  985.   Unfortunately I don't know who is the creator of this font and where
  986.   the official site is. I'll put this font in my FTP directory
  987.   <ftp://ftp.netvision.net.il/home/b/belikoff/cyrillic>.
  988.  
  989.   To setup the font for dosemu you should
  990.  
  991.   ╖  Introduce this font to the X. This is described in ``X fonts
  992.      setup''.
  993.  
  994.   ╖  Introduce this font to dosemu. If the font just replaces the
  995.      original vga font, then it will be recognized by default.
  996.      Otherwise, you have to describe it in /etc/dosemu.conf:
  997.  
  998.      # Font to use (without filename extensions). For example:
  999.      X { updatefreq 8 title "MS DOS" icon_name "xdos" font "vga-alt"}
  1000.  
  1001.   Finally, you have to load a keyboard driver. Note, the you don't need
  1002.   a screen driver for the X window. Therefore, not all drivers will
  1003.   work. At least two will: rk by A. Strakhov, and cyrkeyb by Pete
  1004.   Kvitek.
  1005.  
  1006.   8.4.  emacs
  1007.  
  1008.   The minimal cyrillic support in emacs is done by adding the following
  1009.   calls to one's .emacs (provided that the Cyrillic character set
  1010.   support is installed for console or X respectively):
  1011.  
  1012.   (standard-display-european t)
  1013.  
  1014.   (set-input-mode (car (current-input-mode))
  1015.      (nth 1 (current-input-mode))
  1016.      0)
  1017.  
  1018.   This allows the user to view and input documents in Russian.
  1019.  
  1020.   However, such mode is not of a big convenience because emacs doesn't
  1021.   recognize the usual keyboard commands while set in Cyrillic input
  1022.   mode. There are a number of packages which use the different approach.
  1023.   They don't rely on the input mode stuff established by the environment
  1024.   (either X or console. Instead, they allow the user to switch the input
  1025.   mode by the special emacs command and emacs itself is responsible for
  1026.   re-mapping the character set. The author took a chance to look at
  1027.   three of them. The russian.el
  1028.   <http://www.math.uga.edu/~valery/russian.el> package by Valery Alexeev
  1029.   (valery@math.uga.edu) allows the user to switch between cyrillic and
  1030.   regular input mode and to translate the contents of a buffer from one
  1031.   Cyrillic coding standard to another (which is especially useful while
  1032.   reading the texts imported from MS-DOG).
  1033.  
  1034.   The only inconvenience is that emacs is still treating the russian
  1035.   characters as special ones, so it doesn't recognize russian words'
  1036.   bounds and case changes. To fix it, you have to modify the syntax and
  1037.   case tables of emacs:
  1038.  
  1039.   ;; there is a garbage in the variables below, since SGML doesn't like
  1040.   ;; cyrillic characters. You have to put the uppercase and lowercase
  1041.   ;; parts of the Russian alphabet respectively (see the actual files)
  1042.  
  1043.   (setq *russian-abc-ucase* "*** SGML SUCKS ***")
  1044.   (setq *russian-abc-lcase* "*** SGML SUCKS ***")
  1045.  
  1046.   (let ((i 0)
  1047.         (len (length *russian-abc-ucase*)))
  1048.  
  1049.        (while (< i len)
  1050.          (modify-syntax-entry (elt *russian-abc-ucase* i) "w  ")
  1051.          (modify-syntax-entry (elt *russian-abc-lcase* i) "w  ")
  1052.          (set-case-syntax-pair (elt *russian-abc-ucase* i)
  1053.                                (elt *russian-abc-lcase* i)
  1054.                                (standard-case-table))
  1055.          (setq i (+ i 1))))
  1056.  
  1057.   For this purpose I created a rusup.el file which does this, as well as
  1058.   a couple handy functions. You have to load it in your ~/.emacs.
  1059.  
  1060.   Another alternative is the package remap which tries to make such
  1061.   support more generic. This package is written by Per Abrahamsen
  1062.   (abraham@iesd.auc.dk) and is accessible at ftp.iesd.auc.dk.
  1063.  
  1064.   As for the author's opinion, I would suggest to start using the
  1065.   russian.el package because it is very easy to setup and use.
  1066.  
  1067.   8.5.  ispell
  1068.  
  1069.   There is an rspell add-on created by Neal Dalton (nrd@cray.com) for
  1070.   the GNU ispell package, but I experienced some problems making it work
  1071.   right away. Try it - maybe you will be luckier.
  1072.  
  1073.   8.6.  joe
  1074.  
  1075.   Try the -asis option.
  1076.  
  1077.   8.7.  ksh
  1078.  
  1079.   As for the public domain ksh implementation - pdksh 5.1.3, you can
  1080.   input 8 bit characters only in vi input mode. Use:
  1081.  
  1082.   set -o vi
  1083.  
  1084.   8.8.  less
  1085.  
  1086.   So far, less doesn't support the KOI-8 character set, but the
  1087.   following environment variable will do the job:
  1088.  
  1089.   LESSCHARSET=latin1
  1090.  
  1091.   8.9.  lynx
  1092.  
  1093.   As of version 2.6, you may select the appropriate value for the
  1094.   display Character set opetion.
  1095.  
  1096.   8.10.  mc (The Midnight Commander)
  1097.  
  1098.   To display Cyrillic text correctly, select the full 8 bits item in the
  1099.   Options/Display menu.
  1100.  
  1101.   If your problem is the ugly windows' borders, consult the ``''
  1102.   section.
  1103.  
  1104.   As an off-topic, if you want to make mc use color in an Xterm window,
  1105.   set the variable COLORTERM:
  1106.  
  1107.   COLORTERM= ; export COLORTERM
  1108.  
  1109.   8.11.  Netscape navigator
  1110.  
  1111.   Make sure you are using Netscape version higher than 3. If your
  1112.   Netscape is older, download a new one from www.netscape.com.
  1113.  
  1114.   8.11.1.  Basic setup
  1115.  
  1116.   To be able to see Cyrillic text in most parts of the HTML document, do
  1117.   the following:
  1118.  
  1119.   ╖  In menu Options/Document Encoding select Cyrillic(KOI-8).
  1120.  
  1121.   ╖  In menu Options/General Preferences/Fonts select Cyrillic (KOI-8)
  1122.      encoding, Times(Cronyx) as a proportional font and Courier(Cronyx)
  1123.      as a fixed one.
  1124.  
  1125.   ╖  save options.
  1126.  
  1127.   NOTE: This setup will work with most parts of the document. However,
  1128.   you won't be able to display Cyrillic text in the window header, menus
  1129.   and some controls. To fix these problems, do an
  1130.  
  1131.   8.11.2.  Cyrillic text in frames and input areas
  1132.  
  1133.   To fix this, it is usually enough to:
  1134.  
  1135.   1. Copy the Netscape properties database (usually Netscape.ad) to
  1136.      ~/Netscape.
  1137.  
  1138.   2. In the latter file, set the following property:
  1139.  
  1140.      *documentFonts.charset*iso8859-1:           koi8-r
  1141.  
  1142.   This will force all frame and input elements to use the fonts with
  1143.   koi8-r encoding instead of the default ones, therefore you have to
  1144.   make sure you have installed such fonts (see section ``'').
  1145.  
  1146.   8.11.3.  Advanced setup
  1147.  
  1148.   Andrew A. Chernov is the one, who knows more than others about KOI-8
  1149.   in general and netscape in particular. Visit his excellent KOI-8 page
  1150.   and download a patch for Netscape resource file, making Netscape speak
  1151.   Russian as much as it is able to.
  1152.  
  1153.   8.12.  pine
  1154.  
  1155.   Set the following directive in ~/.pinerc for personal configuration,
  1156.   or in /usr/lib/pine.conf for a global one:
  1157.  
  1158.   character-set=ISO-8859-5
  1159.  
  1160.   8.13.  rlogin
  1161.  
  1162.   Make sure that the shell on the destination site is properly set up.
  1163.   Then, if your rlogin doesn't work by default, use 'rlogin -8'.
  1164.  
  1165.   8.14.  sendmail (aka "The Doom of a Sysadmin")
  1166.  
  1167.   As of version 8, sendmail handles 8-bit data correctly by default. If
  1168.   it doesn't do it for you, check the EightBitMode option and option 7
  1169.   given to mailers in your /etc/sendmail.cf. See "Sendmail. Operation
  1170.   and Installation Guide" for details.
  1171.  
  1172.   8.15.  StarOffice
  1173.  
  1174.   It looks like StarOffice doesn't work with my release of libc.
  1175.   Therefore, I didn't have a chance to try it, let alone to check it's
  1176.   cyrillization ability.
  1177.  
  1178.   Youri Kovalenko () has compiled a concise summary on StarOffice
  1179.   russification. It is located at .  Again, I never had a chance to try
  1180.   it, so I cannot say anything about it's correctness.
  1181.  
  1182.   8.16.  xemacs
  1183.  
  1184.   Basically, xemacs has a very reasonable default setup. However you
  1185.   will still need the package.
  1186.  
  1187.   If something doesn't work, see the section on ``''. This may help.
  1188.  
  1189.   Also, I haven't ported my ``rusup.el'' package to xemacs, so you will
  1190.   lack that functionality. Hopefully, I'll do the port in the near
  1191.   future.
  1192.  
  1193.   8.17.  zsh
  1194.  
  1195.   Use the same way as with csh (see section ``csh''). The startup files
  1196.   in this case are .zshrc or /etc/zshrc.
  1197.  
  1198.   9.  Localization and Internationalization
  1199.  
  1200.   So far, I described how to make various programs understand Cyrillic
  1201.   text. Basically, each program required it's own method, very different
  1202.   from the others. Moreover, some programs had incomplete support of
  1203.   languages other than English. Not to mention their inability to
  1204.   interact using user's mother tongue instead of English.
  1205.  
  1206.   The problems outlined above are very pressing, since software is
  1207.   rarely developed for home market only. Therefore, rewriting
  1208.   substantial parts of software each time the new international market
  1209.   is approached is very ineffective; and making each program implement
  1210.   it's own proprietary solution for handling different languages is not
  1211.   a great idea in a long term either.
  1212.  
  1213.   Therefore, a need for standardization arises. And the standard shows
  1214.   up.
  1215.  
  1216.   Everything related to the problems above is divided by two basic
  1217.   concepts: localization and internationalization. By localization we
  1218.   mean making programs able to handle different language conventions for
  1219.   different countries. Let me give an example. The way date is printed
  1220.   in the United States is MM/DD/YY. In Russia however, the most popular
  1221.   format is DD.MM.YY. Another issues include time representation,
  1222.   printing numbers and currency representation format. Apart from it,
  1223.   one of the most important aspect of localization is defining the
  1224.   appropriate character classes, that is, defining which characters in
  1225.   the character set are language units (letters) and how they are
  1226.   ordered. On the other hand, localization doesn't deal with fonts.
  1227.  
  1228.   Internationalization (or i18n for brevity) is supposed to solve the
  1229.   problems related to the ability of the program interact with the user
  1230.   in his native language.
  1231.  
  1232.   Both of the concepts above had to be implemented in a standard, giving
  1233.   programmers a consistent way of making the programs aware of national
  1234.   environments.
  1235.  
  1236.   Althogh the standard hasn't been finished yet, many parts actually
  1237.   have; so they can be used without much of a problem.
  1238.  
  1239.   I am going to outline the general scheme of making the programs use
  1240.   the features above in a standard way. Since this deserves a separate
  1241.   document, I'll just try to give a very basic description and pointers
  1242.   to more thorough sources.
  1243.  
  1244.   9.1.  Locale
  1245.  
  1246.   One of the main concept of the localization is a locale. By locale is
  1247.   meant a set of conventions specific to a certain language in a certain
  1248.   country. It is usually wrong to say that locale is just country-
  1249.   specific. For example, in Canada two locales can be defined -
  1250.   Canada/English language and Canada/French language. Moreover,
  1251.   Canada/English is not equivalent to UK/English or US/English, just as
  1252.   Canada/French is not equivalent to France/French or
  1253.   Switzerland/French.
  1254.  
  1255.   9.1.1.  How to use locale
  1256.  
  1257.   Each locale is a special database, defining at least the following
  1258.   rules:
  1259.  
  1260.   1. character classification and conversion
  1261.  
  1262.   2. monetary values representation
  1263.  
  1264.   3. number representation (ie. the decimal character)
  1265.  
  1266.   4. date/time formatting
  1267.  
  1268.   In RedHat 4.1, which I am using there are actually two locale
  1269.   databases: one for the C library (libc) and one for the X libraries.
  1270.   In the ideal case there should be only one locale database for
  1271.   everything.
  1272.  
  1273.   To change your default locale, it is usually enough to set the LANG
  1274.   environment variable. For example, in sh:
  1275.  
  1276.   LANG=ru_RU
  1277.   export LANG
  1278.  
  1279.   Sometimes, you may want to change only one aspect of the locale
  1280.   without affecting the others. For example, you may decide (God knows
  1281.   why) to stick with ru_RU locale, but print numbers according to the
  1282.   standard POSIX one. For such cases, there is a set of environment
  1283.   variables, which you can you to configure specific parts for the
  1284.   current locale. In the last exaple it would be:
  1285.  
  1286.   LANG=ru_RU
  1287.   LC_NUMERIC=POSIX
  1288.   export LANG LC_NUMERIC
  1289.  
  1290.   For the full description of those variables, see locale(7).
  1291.  
  1292.   Now let's be more Linux-specific. Unfortunately, Linux libc version
  1293.   5.3.12, supplied with RedHat 4.1, doesn't have a russian locale. In
  1294.   this case one must be downloaded from the Internet (I don't know the
  1295.   exact address, however).
  1296.  
  1297.   To check, locale for which languages you have, run 'locale -a'. It
  1298.   will list all locale databases, available to libc.
  1299.  
  1300.   Fortunately, Linux community is rapidly moving to the new GNU libc
  1301.   (glibc version 2, which is much more POSIX-compliant and has a proper
  1302.   russian locale. Next "stable" RedHat system will already use glibc.
  1303.  
  1304.   As for the X libraries, they have their own locale database. In the
  1305.   version I am using (XFree86 3.3), there already is a russian locale
  1306.   database. I am not sure about the previous versions. In any case, you
  1307.   may check it by looking into usr/lib/X11/locale/ (on most systems). In
  1308.   my case, there already are subdirectories named koi8-r and even
  1309.   iso8859-5.
  1310.  
  1311.   9.1.2.  Locale-aware programming
  1312.  
  1313.   With locale, program don't have to implement explicitly various
  1314.   character conversion and comparison rules, described above. Instead,
  1315.   they use special API which make use of the rules defined by locale.
  1316.   Also, it is not necessary for program to use the same locale for all
  1317.   rules - it is possible to handle different rules using different
  1318.   locales (although such technique should be strongly discouraged).
  1319.  
  1320.   From the setlocale(3) manual page:
  1321.  
  1322.        A  program  may be made portable to all locales by calling
  1323.        setlocale(LC_ALL, "" ) after program   initialization,  by
  1324.        using  the  values  returned  from a localeconv() call for
  1325.        locale - dependent information and by using  strcoll()  or
  1326.        strxfrm() to compare strings.
  1327.  
  1328.   SunSoft, for example, defines 5 levels of program localization:
  1329.  
  1330.   1. 8-bit clean software. That is, the program calls setlocale(), it
  1331.      doesn't make any assumptions about the 8th bit of each character,
  1332.      it users functions from ctype.h and limits from limits.h, and it
  1333.      takes care about signed/unsigned issues.
  1334.  
  1335.      It is very important not to do any assumption about the character
  1336.      set nature and ordering. The following programming practices must
  1337.      be avoided:
  1338.  
  1339.          if (c >= 'A' && c <= 'Z') {
  1340.              ...
  1341.  
  1342.   Instead, macros from the ctype.h header file are locale-aware and
  1343.   should be used in all such occasions.
  1344.  
  1345.   2. Formats, sorting methods, paper sizes. The program uses strcoll()
  1346.      and strxfrm() instead of strcmp() for strings, it uses time(),
  1347.      localtime(), and strftime()/ for time services, and finally, it
  1348.      uses localeconv() for a proper numbers and currency representation.
  1349.  
  1350.   3. Visible text in message catalogs. The program must isolate all
  1351.      visible text in special message catalogs. Those map strings in
  1352.      English to their translation to other languages. Selection of
  1353.      messages in an appropriate for a particular environment language is
  1354.      done in a way which is completely transparent for both the program
  1355.      and it's user. To make use of those facilities, the program must
  1356.      call gettext() (Sun/POSIX standard), or catgets() (X/Open
  1357.      standard). For more information on that see section ``''.
  1358.  
  1359.   4. EUC/Unicode support. At this level, the program doesn't use the
  1360.      char type. Instead it uses wchar_t, which defines entities big
  1361.      enough to contain Unicode characters. ANSI C defines this data type
  1362.      and an appropriate API.
  1363.  
  1364.   For a more detaled explanation of locale, see, for example (``'') or
  1365.   (``'').
  1366.  
  1367.   9.2.  Internationalization
  1368.  
  1369.   While localization describes, how to adapt a program to a foreign
  1370.   environment, internationalization (or i18n for brevity) details the
  1371.   ways to make program communicate with a non-English speaking user.
  1372.  
  1373.   Before, that was done by developing some abstraction of the messages
  1374.   to output from the program's code. Now, such mechanism is (more or
  1375.   less) standardized. And, of course, there are free implementations of
  1376.   it!
  1377.  
  1378.   The GNU project has finally adopted the way of making the
  1379.   internationalized applications. Ulrich Drepper (drepper@ipd.info.uni-
  1380.   karlsruhe.de) developed a package gettext. This package is available
  1381.   at all GNU sites like prep.ai.mit.edu. It allows you to develop
  1382.   programs in the way that you can easily make them support more
  1383.   languages. I don't intend to describe the programming techniques,
  1384.   especially because the gettext package is delivered with excellent
  1385.   manual.
  1386.  
  1387.   Request for collaboration: If you want to learn the gettext package
  1388.   and to contribute to the GNU project simultaneously; or even if you
  1389.   just want to contribute, then you can do it! GNU goes international,
  1390.   so all the utilities are being made locale-aware. The problem is to
  1391.   translate the messages from English to Russian (and other languages if
  1392.   you'd like). Basically, what one has to do is to get the special .po
  1393.   file consisting of the English messages for a certain utility and to
  1394.   append each message with it's equivalent in Russian. Ultimately, this
  1395.   will make the system speak Russian if the user wants it to! For more
  1396.   details and further directions contact Ulrich Drepper
  1397.   (drepper@ipd.info.uni-karlsruhe.de).
  1398.   10.  Useful Tools
  1399.  
  1400.   10.1.  Conversion Utilities
  1401.  
  1402.   There are a number of programs able to convert from KOI-8 to Alt and
  1403.   back. Look at SovInformBureau or ftp.funet.fi for a list of handy
  1404.   little utilities. You can even use the special mode for emacs (see
  1405.   section ``Emacs'').
  1406.  
  1407.   However, I would especially recommend a translit package. It supports
  1408.   many popular codesets and is even able to produce a *TeX files (see
  1409.   section ``'') from text in Russian. Also, RedHat users will enjoy an
  1410.   RPM package for translit.
  1411.  
  1412.   11.  Bibliography
  1413.  
  1414.   1. Andrey Chernov. KOI-8 <http://www.nagual.ru/~ache/koi8.html>. KOI-8
  1415.      information and setup.
  1416.  
  1417.   2. Ulrich Drepper. Internationalization in the GNU project
  1418.      <http://i44www.info.uni-karlsruhe.de/~drepper/conf96/paper.html>.
  1419.      Very thorough description of a GNU approach to i18n.
  1420.  
  1421.   3. Michael Karl Gschwind. Internationalization
  1422.      <http://www.vlsivie.tuwien.ac.at/mike/i18n.html>. Various resources
  1423.      on i18n.
  1424.  
  1425.   4. Sergei Naumov. Information on Cyrillic Software
  1426.      <http://sunsite.oit.unc.edu/sergei/Software/Software.html>.
  1427.      Cyrillic setup information.
  1428.  
  1429.   5. The Open Group Single UNIX specification <http://www.UNIX-
  1430.      systems.org/online.html>.
  1431.  
  1432.   6. Alec Voropay. Localization as it is
  1433.      <http://www.sensi.org/~alec/locale>. General locale usage in
  1434.      Russian.
  1435.  
  1436.   12.  Summary of the various useful resources
  1437.  
  1438.   a2ps homepage <http://www-inf.enst.fr/~demaille/a2ps.html>
  1439.  
  1440.   General Linux Information <http://sunsite.unc.edu/mdw/linux.html>
  1441.  
  1442.   Collection of Cyrillic stuff on ftp.kiae.su
  1443.   <ftp://ftp.kiae.su/cyrillic/>
  1444.  
  1445.   Collection of Cyrillic stuff on ftp.relcom.ru
  1446.   <ftp://ftp.relcom.ru/cyrillic/>
  1447.  
  1448.   Collection of cyrilization software
  1449.   <ftp://ftp.funet.fi/pub/culture/russian/comp/>
  1450.  
  1451.   Cronyx <http://www.cronyx.ru> - the creators of Cyrillic fonts for the
  1452.   X Window System.
  1453.  
  1454.   Cyrillic fonts for Ghostscript
  1455.   <ftp://ftp.kapella.gpi.ru/pub/cyrillic/psfonts>
  1456.  
  1457.   Cyrillic fonts for X
  1458.   <ftp://ftp.kiae.su/cyrillic/x11/fonts/xrus-2.1.1-src.tgz>
  1459.  
  1460.   Ghostscript <http://www.cs.wisc.edu/~ghost/index.html>
  1461.  
  1462.   GNU enscript <ftp://prep.ai.mit.edu/pub/gnu>
  1463.  
  1464.   relcom.fido.ru.unix newsgoup.
  1465.  
  1466.   RFC 1489 <file://ds.internic.net/rfc/rfc1489.txt>
  1467.  
  1468.   rspell for GNU ispell <ftp://sunsite.unc.edu/pub/academic/russian-
  1469.   studies/Software/rspell.tar.gz>
  1470.  
  1471.   SovInformBureau <http://www.siber.com/sib/russify/>
  1472.  
  1473.   teTeX russification package <ftp://xray.sai.msu.su/pub/outgoing/teTeX-
  1474.   rus/>
  1475.  
  1476.   The kbd package for Linux
  1477.   <ftp://sunsite.unc.edu/pub/Linux/system/Keyboards/>
  1478.  
  1479.   The remap package for Emacs <ftp://ftp.iesd.auc.dk/>
  1480.  
  1481.   The rtxt2ps package <http://www.siber.com/sib/russify/converters/>
  1482.  
  1483.   The russian.el package for emacs
  1484.   <http://www.math.uga.edu/~valery/russian.el>
  1485.  
  1486.   The translit package
  1487.   <ftp://ftp.osc.edu/pub/russian/translit/translit.tar.Z>
  1488.  
  1489.   The xruskb package <ftp://ftp.relcom.ru/pub/x11/cyrillic/>
  1490.  
  1491.   Useful Cyrillic packages <ftp://sunsite.unc.edu/pub/academic/russian-
  1492.   studies/Software>
  1493.  
  1494.   X fonts collections <ftp://ftp.switch.ch/mirror/linux/X11/fonts/>
  1495.  
  1496.   XFree86 FTP site <http://www.xfree86.org>
  1497.  
  1498.